#include "vrepconfigview.h"
#include "ui_vrepconfigview.h"
#include <QDebug>


VrepConfigView::VrepConfigView(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::VrepConfigView)
{
    ui->setupUi(this);
    ui->comboBox_io_mode->setCurrentIndex( 0 );
    ui->comboBox_motor_mode->setCurrentIndex( 0 );
}

VrepConfigView::~VrepConfigView()
{
    delete ui;
}

void VrepConfigView::on_comboBox_motor_mode_currentIndexChanged(int index)
{
    emit signal_setVrepServoType(  index );
}

void VrepConfigView::on_comboBox_io_mode_currentIndexChanged(int index)
{
    emit signal_setVrepIoType(  index );
}

void VrepConfigView::on_pushButton_StartVrep_toggled(bool checked)
{
    if( checked )
    {
        qDebug("connnect vrep! ");
        emit signal_connectVrep(ui->lineEdit_ip->text() ,ui->spinBox_vrep_port->value() );
    }else{
        qDebug( "disconnect from vrep server !" );
        emit signal_disconnectVrep();
    }

    ui->lineEdit_ip->setEnabled(checked);
    ui->spinBox_vrep_port->setEnabled(checked);
}

void VrepConfigView::on_pushButton_StartVrep_2_clicked()
{
    hide();
}
